from rest_framework import serializers
from .models import Tenant

class BaseSerializer(serializers.ModelSerializer):
    id = serializers.CharField()

    class Meta:
        model = Tenant

# 列表数据序列化
class ListSerializer(BaseSerializer):
    class Meta(BaseSerializer.Meta):
        fields = "__all__"

# 下拉选择项数据序列化
class SelectSerializer(BaseSerializer):
    label = serializers.CharField(source="tenantName")
    value = serializers.CharField(source="id")
    class Meta(BaseSerializer.Meta):
        fields = ['id','label','value']

# 详情数据序列化
class DetailSerializer(BaseSerializer):
    class Meta(BaseSerializer.Meta):
        fields = "__all__"